# load sample data
data4D = img2float(cells3d())
data = data4D[:, 1 , :, :] # load the nuclei channel
Downloading file 'data/cells3d.tif' from 'https://gitlab.com/scikit-image/data/-/raw/master/cells3d.tif' to '/home/biagio/.var/app/com.visualstudio.code/cache/scikit-image/0.19.3'.
Display 2D images
Function to quickly display 2D images
source
plot_image
plot_image (values)
Plot a 2D image using Matplotlib. The function assumes that ‘values’ is a 2D array representing an image, typically in grayscale.
values
A 2D array of pixel values representing the image.
# Example usage:
plot_image(data[35 ])
Display Multichannel images
Function to display RGB and multichannel images
source
show_multichannel
show_multichannel (img, ax=None, figsize=None, title=None, max_slices=3,
ctx=None, layout='horizontal', num_cols=3, cmap=None,
norm=None, aspect=None, interpolation=None,
alpha=None, vmin=None, vmax=None, origin=None,
extent=None, interpolation_stage=None,
filternorm=True, filterrad=4.0, resample=None,
url=None, data=None, **kwargs)
Show multi-channel CYX image with options for horizontal, square, or multi-row layout.
img
A tensor or numpy array representing a multi-channel image.
ax
NoneType
None
The Matplotlib axis to use for plotting.
figsize
NoneType
None
The size of the figure.
title
NoneType
None
The title of the image.
max_slices
int
3
The maximum number of slices to display.
ctx
NoneType
None
The context to use for plotting.
layout
str
horizontal
The layout type: ‘horizontal’, ‘square’, or ‘multirow’.
num_cols
int
3
The number of columns for the ‘multirow’ layout. Ignored for other layouts.
cmap
NoneType
None
norm
NoneType
None
aspect
NoneType
None
interpolation
NoneType
None
alpha
NoneType
None
vmin
NoneType
None
vmax
NoneType
None
origin
NoneType
None
extent
NoneType
None
interpolation_stage
NoneType
None
filternorm
bool
True
filterrad
float
4.0
resample
NoneType
None
url
NoneType
None
data
NoneType
None
kwargs
print (data4D[35 ].shape)
show_multichannel(data4D[35 ], cmap= 'gray' , layout= 'multirow' , num_cols= 1 );
Display 3D images
Function to display 3D images
source
mosaic_image_3d
mosaic_image_3d (t:(<class'numpy.ndarray'>,<class'torch.Tensor'>),
axis:int=0, figsize:tuple=(15, 15), cmap:str='gray',
nrow:int=10, alpha=1.0, return_grid=False,
add_to_existing=False, **kwargs)
Plots 2D slices of a 3D image alongside a prior specified axis.
t
(<class ‘numpy.ndarray’>, <class ‘torch.Tensor’>)
3D image to plot
axis
int
0
axis to split 3D array to 2D images
figsize
tuple
(15, 15)
size of the figure
cmap
str
gray
colormap to use
nrow
int
10
number of images per row
alpha
float
1.0
transparency of the image
return_grid
bool
False
return the grid for further processing
add_to_existing
bool
False
add to existing figure
kwargs
source
show_images_grid
show_images_grid (images, ax=None, ncols=10, figsize=None, title=None,
spacing=0.02, max_slices=3, ctx=None, cmap=None,
norm=None, aspect=None, interpolation=None, alpha=None,
vmin=None, vmax=None, origin=None, extent=None,
interpolation_stage=None, filternorm=True,
filterrad=4.0, resample=None, url=None, data=None,
**kwargs)
*Show a list of images arranged in a grid.
Returns: - axes: matplotlib axes containing the grid of images.*
images
A list of images to display.
ax
NoneType
None
The Matplotlib axis to use for plotting.
ncols
int
10
The number of columns in the grid.
figsize
NoneType
None
The size of the figure.
title
NoneType
None
The title of the image.
spacing
float
0.02
The spacing between subplots.
max_slices
int
3
The maximum number of slices to display.
ctx
NoneType
None
The context to use for plotting.
cmap
NoneType
None
norm
NoneType
None
aspect
NoneType
None
interpolation
NoneType
None
alpha
NoneType
None
vmin
NoneType
None
vmax
NoneType
None
origin
NoneType
None
extent
NoneType
None
interpolation_stage
NoneType
None
filternorm
bool
True
filterrad
float
4.0
resample
NoneType
None
url
NoneType
None
data
NoneType
None
kwargs
mosaic_image_3d(torch_from_numpy(data), figsize= None )
show_images_grid(data, cmap= 'gray' );
Show slices
source
show_plane
show_plane (ax, plane, cmap='gray', title=None, lines=None,
linestyle='--', linecolor='white')
Display a slice of the image tensor on a given axis with optional dashed lines.
ax
The axis object to display the slice on.
plane
A 2D numpy array representing the slice of the image tensor.
cmap
str
gray
Colormap to use for displaying the image.
title
NoneType
None
Title for the plot.
lines
NoneType
None
A list of indices where dashed lines should be drawn on the plane.
linestyle
str
–
The style of the dashed lines.
linecolor
str
white
The color of the dashed lines.
source
visualize_slices
visualize_slices (data, planes=None, showlines=True, **kwargs)
Visualize slices of a 3D image tensor along its planes, rows, and columns.
data
A 3D numpy array representing the image tensor.
planes
NoneType
None
A tuple containing the indices of the planes to visualize.
showlines
bool
True
Whether to show dashed lines on the planes, rows, and columns.
kwargs
visualize_slices(data, showlines= False )
visualize_slices(data, (25 ,100 ,150 ), linestyle= ':' )
source
slice_explorer
slice_explorer (data, order='CZYX', **kwargs)
Visualizes the provided data using Plotly’s interactive imshow function with animation support.
data
A 3D numpy array representing the image tensor.
order
str
CZYX
The order of dimensions in the data.
kwargs
slice_explorer(data4D, order= 'ZCYX' , title= 'Cells 3D' )
source
plot_volume
plot_volume (values, opacity=0.1, min=0.1, max=0.8, surface_count=5,
width=800, height=600)
*Plot a 3D volume using Plotly. The function assumes that ‘values’ is a 3D array representing the volume data.
Parameters: values (numpy.ndarray): A 3D array of pixel values representing the volume. opacity (float, optional): Opacity level for the surfaces in the volume plot. Defaults to 0.1. min (float, optional): Minimum threshold multiplier for the visualization. Defaults to 0.1. max (float, optional): Maximum threshold multiplier for the visualization. Defaults to 0.8. surface_count (int, optional): Number of surfaces to display in the volume plot. Defaults to 5. width (int, optional): Width of the plotted figure. Defaults to 800. height (int, optional): Height of the plotted figure. Defaults to 600.
Returns: None*
plot_volume(data[:, 50 :150 , 50 :150 ])
Unable to display output for mime type(s): application/vnd.plotly.v1+json